-
Notifications
You must be signed in to change notification settings - Fork 76
RFC #48: Split 'assert_precondition' into optional and non-optional variants #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
614f2f1
RFC #43 - rename assert_precondition
stephenmcgruer 30a5ec5
Do not compare to assert_true
stephenmcgruer 2391dfb
Minor fixup
stephenmcgruer fb06c0d
s/i.e./e.g./
stephenmcgruer aacec93
Update rfcs/assert_precondition_rename.md
stephenmcgruer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# RFC 43: Split 'assert\_precondition' into optional and non-optional variants | ||
|
||
## Summary | ||
|
||
Split the `assert_precondition` function into `assert_implements_optional` and | ||
`assert_implements`. The `assert_implements_optional` function will behave as | ||
`assert_precondition` does today; a failed assert will record a | ||
'PRECONDITION\_FAILED' status. The `assert_implements` function behaves | ||
similarly, but records a 'FAIL' status if the assert fails. | ||
|
||
Reuse the 'PRECONDITION\_FAILED' status rather than renaming it due to the | ||
technical difficulties of getting mozlog updated. | ||
|
||
## Details | ||
|
||
### Background | ||
|
||
The `assert_precondition` function and associated status | ||
('PRECONDITION\_FAILED') were added in [RFC #16](assert_precondition.md). | ||
However there has been confusion over whether the function is meant for spec | ||
features that are explicitly marked OPTIONAL (e.g. its usage in | ||
`html/semantics/embedded-content/the-video-element/resize-during-playback.html`), | ||
or whether it is meant as an early-out when a particular spec or feature is not | ||
implemented by a browser (e.g. its usage in `portals/`). | ||
|
||
The difference matters here due to the 'PRECONDITION\_FAILED' status, which has | ||
been interpreted by some users as a 'non-failing' status - which only makes | ||
sense if the failure is for truly OPTIONAL behavior. | ||
|
||
### Proposal | ||
|
||
Rename the `assert_precondition` function to `assert_implements_optional`, with | ||
the same 'PRECONDITION\_FAILED' status produced, and add a new function | ||
`assert_implements` that produces a 'FAIL' status if the input is not | ||
[truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy). That is: | ||
|
||
> __assert_implements(condition, description)__ | ||
> | ||
> Concludes the test with a `FAIL` status if `condition` is not | ||
> [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy). | ||
> Used to avoid running unnecessary code or subtests for a feature that is not | ||
> implemented by the running browser. | ||
|
||
> __assert_implements_optional(condition, description)__ | ||
> | ||
> Concludes the test with a `PRECONDITION_FAILED` status if `condition` is not truthy. | ||
> Used for skipping tests or subtests for OPTIONAL features that that would otherwise | ||
> fail due to lack of support for the feature. | ||
|
||
The 'PRECONDITION\_FAILED' status is not being renamed, as changing the logging | ||
infrastructure (mozlog, etc) is logistically difficult. | ||
|
||
## Risks | ||
|
||
* As with any change in testharness.js, downstream embedders may have to spend | ||
effort to adapt to the deprecation and rename. That said, there are currently | ||
zero uses of `assert_precondition` in downstream Chromium tests. | ||
* As it is not being renamed, the 'PRECONDITION\_FAILED' status may confuse | ||
consumers of WPT results. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.